---------------------------------------------------------------------- Mailing Compressed Directories and Binary Files Last update: 16 August 1995 Confluent Technical Notes Copyright (c) 1995 Confluent, Inc. All rights reserved. Suggestions or questions to 415-586-8700 or vthought@confluent.com. ---------------------------------------------------------------------- This technical note describes techniques for efficiently sending multiple directories and files via email. It is often useful to send directories, large files, and/or binary files via email. For example: Visual Thought documents screen shots (e.g., images obtained with Options->XGrab->Selection in VT) images (e.g., GIF files) To accomplish this easily and efficiently, the information should be placed in an archive, compressed, and converted to a text form that can be attached to or included in an email message. This approach offers the following advantages: 1. It handles multiple files, multiple directories, and entire directory structures with a single command without requiring individual treatment of each file. One email attachment can be generated for all files and directories being sent. 2. It deals with binary files in a transparent manner. There is no need to encode them separately. 3. It can significantly reduce the size of the resulting email message. Some files, such as Visual Thought documents, can be compressed substantially. The packinfo csh script attached to the end of this note archives, compresses, and uuencodes specified files and/or directories for transmission via email. To set up packinfo, extract it from this note (get everything between the "===== begin" and "===== end" lines), place it in the file packinfo, and make it executable with: chmod +x packinfo The packinfo script uses the gzip command, if available, because gzip achieves much better compression than compress. If you do not have gzip, but you do have gunzip, you can create gzip by creating a link from gunzip to gzip (they are the same executable with different names) with: ln gunzip gzip If you do not have gunzip, packinfo will use compress instead. If you want a copy of gunzip, let us know and we will get you a copy. Execute packinfo with: packinfo where are the paths of one or more files and/or directories. Packinfo creates the file data.uue, which is in text form. It can be attached directly to a mail message (e.g., in mailtool) or included in the text of a mail message. The contents of data.uue can be recovered with: uudecode data.uue gunzip data.tar tar xf data.tar Replace gunzip with uncompress in the above commands if the first line of data.uue contains data.tar.Z, rather than data.tar.gz (i.e., packinfo used compress instead of gzip). ===== begin packinfo ===== #!/bin/csh -f # Indicate usage. if ($#argv < 1) then set cmd = $0 echo "usage: $cmd:t " echo "" echo " Archives, compresses, and uuencodes to data.uue, which can" echo " be attached to mail (e.g., in mailtool) or included in a mail message." echo "" exit endif # Determine which compression command to use by finding the first # command in $cmd_array that exists in the command search path. set cmd_array = ("gzip" "compress") set ext_array = ("gz" "Z") @ index = 0 @ i = 0 while ($i < $#cmd_array) @ i ++ foreach dir ($path) if (-x $dir/$cmd_array[$i]) then set index = $i break; break endif end end # Indicate that none of the compression commands could be found. if ($index == 0) then echo "" echo "None of the following compression commands could be found in your" echo "command search path:" echo "" echo " $cmd_array" echo "" exit endif # Generate the output file. set ext = $ext_array[$index] tar cf data.tar $* $cmd_array[$index] data.tar uuencode data.tar.$ext data.tar.$ext > data.uue rm data.tar.$ext ===== end packinfo =====